//
//  AddFriendAlert.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/24.
//

#import "AddFriendAlert.h"
#import "CommonUtil.h"

@interface AddFriendAlert()

@property (strong, nonatomic) UILabel * titleLabel;

@property (strong, nonatomic) UILabel * nickLabel;
@property (strong, nonatomic) UITextField * nickField;
@property (strong, nonatomic) UIView * nickLine;

@property (strong, nonatomic) UILabel * nickLabel2;
@property (strong, nonatomic) UITextField * nickField2;
@property (strong, nonatomic) UIView * nickLine2;

@property (strong, nonatomic) UIButton * addBtn;

@end

@implementation AddFriendAlert

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.whiteView];
        self.whiteView.layer.cornerRadius = AD(10);

    }
    return self;
}

-(void)show{
 
    [super show];
    
    self.whiteView.frame = CGRectMake(AD(30), 0, SCREEN_WIDTH-AD(60), AD(300));
    self.whiteView.centerY = SCREEN_HEIGHT/2;
    [self.whiteView addSubview:self.titleLabel];
    [self.whiteView addSubview:self.nickLabel];
    [self.whiteView addSubview:self.nickField];
    [self.whiteView addSubview:self.nickLine];
    [self.whiteView addSubview:self.nickLabel2];
    [self.whiteView addSubview:self.nickField2];
    [self.whiteView addSubview:self.nickLine2];
    [self.whiteView addSubview:self.addBtn];
    
    
}
   

- (void)addBtnClick:(UIButton *)sender{
    
    if (self.actionBlock) {
        self.actionBlock(@"33");
    }
    NSLog(@"添加好友");
}


-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, AD(10), self.whiteView.width, AD(50))];
        _titleLabel.textColor = [UIColor blackColor];
        _titleLabel.font = [UIFont systemFontOfSize:AD(24)];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.text = @"添加好友";
    }
    return _titleLabel;
}


- (UILabel *)nickLabel{
    if (!_nickLabel) {
        _nickLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, AD(80), AD(80), AD(40))];
        _nickLabel.font = [UIFont systemFontOfSize:AD(20)];
        _nickLabel.text = @"昵称:";
        _nickLabel.textColor = [UIColor blackColor];
        _nickLabel.textAlignment = NSTextAlignmentRight;
    }
    return _nickLabel;
}


- (UITextField *)nickField{
    if (!_nickField) {
        _nickField = [[UITextField alloc] initWithFrame:CGRectMake(_nickLabel.right + AD(10), _nickLabel.top, self.whiteView.width - _nickLabel.right - AD(10), AD(40))];
        _nickField.font = [UIFont systemFontOfSize:AD(20)];
        _nickField.placeholder = @"请输入昵称";
        _nickField.textColor = [UIColor blackColor];
    }
    return _nickField;
}


-(UIView *)nickLine{
    if (!_nickLine) {
        _nickLine = [[UIView alloc] initWithFrame:CGRectMake(AD(30),_nickLabel.bottom + AD(5), self.whiteView.width - AD(60), AD(1))];
        _nickLine.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
    }
    return _nickLine;
}


- (UILabel *)nickLabel2{
    if (!_nickLabel2) {
        _nickLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(0, _nickLine.bottom + AD(10), AD(80), AD(40))];
        _nickLabel2.font = [UIFont systemFontOfSize:AD(20)];
        _nickLabel2.text = @"留言:";
        _nickLabel2.textColor = [UIColor blackColor];
        _nickLabel2.textAlignment = NSTextAlignmentRight;
    }
    return _nickLabel2;
}


- (UITextField *)nickField2{
    if (!_nickField2) {
        _nickField2 = [[UITextField alloc] initWithFrame:CGRectMake(_nickLabel2.right + AD(10), _nickLabel2.top, self.whiteView.width - _nickLabel2.right - AD(10), AD(40))];
        _nickField2.font = [UIFont systemFontOfSize:AD(20)];
        _nickField2.placeholder = @"禁止添加联系方式";
        _nickField2.textColor = [UIColor blackColor];
    }
    return _nickField2;
}


-(UIView *)nickLine2{
    if (!_nickLine2) {
        _nickLine2 = [[UIView alloc] initWithFrame:CGRectMake(AD(30),_nickLabel2.bottom + AD(5), self.whiteView.width - AD(60), AD(1))];
        _nickLine2.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
    }
    return _nickLine2;
}



-(UIButton *)addBtn{
    if (!_addBtn) {
        _addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addBtn addTarget:self action:@selector(addBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_addBtn setTitle:@"添加" forState:UIControlStateNormal];
        [_addBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _addBtn.titleLabel.font = [UIFont systemFontOfSize:AD(20)];
        _addBtn.layer.cornerRadius = AD(5);
        _addBtn.backgroundColor = RGB(255.0, 90.0, 117.0);
        CGFloat w = self.whiteView.width - AD(60);
        _addBtn.frame = CGRectMake(AD(30), _nickLine2.bottom + AD(40), w, AD(45));
    }
    
    return _addBtn;
}

@end
